package com.thinkgem.jeesite.modules.tb_message.service;

import java.util.ArrayList;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.socket.TextMessage;

import com.thinkgem.jeesite.modules.tb_certificate_vehicles.service.TbCertificateVehiclesService;
import com.thinkgem.jeesite.modules.tb_message.webSocket.SystemWebSocketHandler;

@Service
@Lazy(false)
public class WebSocketService  {
	@Autowired
	private TbCertificateVehiclesService tbCertificateVehiclesService;	
	public int getUnReadNews (String id){		
		return 1;
	}
	//@Scheduled(cron = "0/20 * * * * ?")
	public void send(){
		ArrayList<Map<String,String>> list=tbCertificateVehiclesService.certificatesalarm();
		String msgg="";
		for (Map<String,String> map : list) {
			msgg="车辆编号："+map.get("carNum")+","+
					"车牌号："+map.get("carCode")+","+					
					map.get("dataType")+"为："+
					map.get("certificatesDate")+","+
					"还有"+map.get("timedifferences")+"天到期！请尽快处理！";
			String msg = "<div class='external-event bg-aqua ui-draggable ui-draggable-handle' style='position: relative;'>"+msgg+"</div>";
			SystemWebSocketHandler.sendMsgToUser("1", new TextMessage(msg));
		}	
	}	
}
